package com.itheima_11;

import java.util.ArrayList;

public class test_11_2 {
    public static void main(String[] args) {
        int max=0;
        ArrayList<Student> list=new ArrayList();
        Student stu=new Student("SD",25,"男");
        Student stu1=new Student("fsf",23,"男");
        Student stu2=new Student("fsjf",26,"女");
        list.add(stu);
        list.add(stu1);
        list.add(stu2);
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).getAge()>max){
                max=list.get(i).getAge();
            }
        }
        for (int i = 0; i < list.size(); i++) {
            if(max==list.get(i).getAge()){
                list.get(i).setName("小猪佩奇");
            }
        }
        System.out.println(list);
    }
}